/*
 * @Author: hongbin
 * @Date: 2022-12-22 10:25:33
 * @LastEditors: hongbin
 * @LastEditTime: 2022-12-24 11:27:43
 * @Description:查询动态
 */
import { ObjectId } from "mongodb";
import { NextApiRequest, NextApiResponse } from "next";
import DB from "../mongodb";
import { AllowCORS } from "../utils";

export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
    const db = await DB;
    const { id } = req.query;
    if (!id) return res.status(501).json({ code: -1, msg: "未传递参数id" });
    const list = await db.collection("dynamic").find({ userId: id }).toArray();
    res.json(list);
}
